package com.ctshk.sapp.goods.controller;


import com.ctshk.common.annotations.OperationLogAnnotation;
import com.ctshk.common.dto.Result;
import com.ctshk.common.enums.OperationLogModel;
import com.ctshk.common.enums.OperationLogType;
import com.ctshk.common.model.PageResponse;
import com.ctshk.common.web.support.BaseController;
import com.ctshk.rpc.goods.dto.CommodityLogDTO;
import com.ctshk.rpc.goods.req.CommodityLogPageReq;
import com.ctshk.rpc.goods.service.ICommodityLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 商品日志表 前端控制器
 * </p>
 *
 * @author 姜斌文
 * @since 2021-04-16
 */
@Api(value="商品日志", tags="商品日志")
@RestController
@RequestMapping("/commodity/log")
public class CommodityLogController extends BaseController {

    @DubboReference
    private ICommodityLogService commodityLogService;

    @ApiOperation(value = "根据商品ID查询日志", notes = "根据商品ID查询日志")
    @OperationLogAnnotation(operModul = OperationLogModel.ORDER, operType = OperationLogType.QUERY, operTitle = "根据商品ID查询日志", operDesc = "根据商品ID查询日志")
    @PostMapping("/findCommodityLogsByCommodityId")
    public Result<PageResponse<CommodityLogDTO>> findCommodityLogsByCommodityId(@RequestBody CommodityLogPageReq pageReq) throws Exception {
        PageResponse<CommodityLogDTO> response = commodityLogService.findCommodityLogsByCommodityId(pageReq, getCurrentUser(getRequest()));
        return Result.success(response);
    }

}
